package main

import (
	"gotask/routes"

	"github.com/gin-gonic/gin"
	"github.com/go-session/gin-session"
)

func main() {
	r := gin.Default()
	r.Use(ginsession.New()) //使用session

	//静态页面设置
	r.Static("/static", "./dist/static")
	r.StaticFile("/", "./dist/index.html")
	r.StaticFile("/index", "./dist/index.html")

	//路由规则 GET /ping func(c *gin.Context)
	r.GET("/ping", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "pong",
		})
	})

	//注册接口
	r.POST("/register", routes.Register)
	//登陆接口
	r.POST("/login", routes.Login)
	//发布任务接口
	r.POST("/issue", routes.Issue)
	//任务修改接口
	r.POST("/update", routes.Update)
	//任务列表查询
	r.GET("/tasklist", routes.Tasklist)

	//启动侦听服务
	r.Run(":9090")
}
